<template>
  <div>
    <div>
      <el-button type="primary"
                 @click="openFrom('add')">添加</el-button>
    </div>
    <dialogForm ref="dialogForm"
                @refresh="getBookList()"></dialogForm>
    <list :bookList="bookList"
          @refresh="getBookList()"></list>
  </div>
</template>

<script>
import list from '@/views/index/component/list.vue'
import dialogForm from '@/views/index/component/dialogForm.vue'
export default {
  components: {
    list,
    dialogForm
  },
  created () {
    this.getBookList();
  },
  data () {
    return {
      bookList: []
    }
  },
  methods: {
    getBookList () {
      this.axios.post('/query/book', {}).then(res => {
        if (res.data.code == '2000') {
          this.bookList = res.data.data
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error'
          });
        }
      })
    },
    openFrom (value1) {
      this.$refs.dialogForm.open(value1);
    }
  }

}
</script>

<style lang="less" scoped>
.ip {
  width: 65%;
}
</style>